package com.angel.controller;

import com.angel.bean.UserInfo;
import com.angel.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 手机端用户登陆
 */
@Controller
@RequestMapping("/l")
public class UserLoginController {
    @Autowired
    private UserInfoService userInfoService;

    @RequestMapping("/userlogin")
    public String user_login(){
        return "user_login";
    }
    /**
     * 登陆时用户名和密码判断
     * @param userTel 登陆的号码
     * @param password 登陆密码
     */
    @RequestMapping("/checknamepwd")
    @ResponseBody
    public Object check_name_pwd(String userTel,String password){
        Map<String,String> map=new HashMap<>();
        UserInfo userInfo=new UserInfo();
        userInfo.setUserName(userTel);
        userInfo.setPassword(password);
        UserInfo result=userInfoService.findOne(userInfo);
        if (result==null){
            System.out.println("------登陆成功-----");
            map.put("emp","true");
        }else {
            System.out.println("------登陆失败-----");
            map.put("emp","false");
        }
        return map;
    }

    @RequestMapping("/login")
    public String login_index() {
        return "user_login";
    }
}
